package com.mark.web.data.controller.backend;

import com.mark.common.ServerResponse;
import com.mark.web.data.entity.po.HeadLine;
import com.mark.web.data.service.IHeadLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Description: Admin 对公告信息控制器的定义
 * @Author: Mark
 * @CreateDate: 2018/8/14.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@RestController
@RequestMapping("/manage/headLine/")
public class HeadLineManageController {

    @Autowired
    private IHeadLineService iHeadLineService;

    //1.发布或者更新公告信息
    @PostMapping(value = "save_headLine.do")
    public ServerResponse headLineSave(HttpSession session, HeadLine headLine){
        return iHeadLineService.insertOrUpdate(headLine);
    }

    //2.获取公告信息列表
    @PostMapping(value = "list.do")
    public ServerResponse getUserList(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
                                      @RequestParam(value = "pageSize",defaultValue = "10") int pageSize,
                                      HttpServletRequest httpServletRequest){
        return iHeadLineService.getHeadLineList(pageNum,pageSize);
    }
}
